package com.zhaopin.qa.jmeter.plugins.multienvuser.config;

import java.io.Serializable;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.testelement.property.BooleanProperty;

public class EnvArgument extends Argument implements Serializable {

	private static final long serialVersionUID = 241L;

	protected static final String GLOBAL = "EnvArgument.global";

	public EnvArgument() {
		this(null, null);
	}

	public EnvArgument(String name, String value) {
		this(name, value, false);
	}

	public EnvArgument(EnvArgument arg) {
		this(arg.getName(), arg.getValue(), arg.getMetaData(), arg.getDescription(), arg.isGlobal());
	}

	public EnvArgument(String name, String value, boolean isGlobal) {
		this(name, value, null, null, isGlobal);
	}

	public EnvArgument(String name, String value, String metadata) {
		this(name, value, metadata, null, false);
	}

	public EnvArgument(String name, String value, String metadata, String description, boolean isGlobal) {
		super(name, value, metadata, description);
		setGlobal(isGlobal);
	}

	public void setGlobal(boolean isGlobal) {
		setProperty(new BooleanProperty(GLOBAL, isGlobal));
	}

	public boolean isGlobal() {
		return getPropertyAsBoolean(GLOBAL);
	}

	public enum ArgumentsType {
		env("环境"), user("用户");

		private String type;

		private ArgumentsType(String type) {
			this.type = type;
		}

		public String getType() {
			return type;
		}
	}
}